/**
 * 
 */
package sob.me.threadapp.demo1;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author blackcore
 * @date 2014年1月17日
 * @describe
 */
public class PigThreadHandler implements Runnable {

	private List<String> siteIds;
	private Integer threadNo;

	public PigThreadHandler(Integer threadNo, List<String> siteIds) {
		this.threadNo = threadNo;
		this.siteIds = siteIds;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Runnable#run()
	 */
	@Override
	public void run() {
		System.out.println("开始线程号：" + this.threadNo + "\t" + new SimpleDateFormat("HH:mm:ss.S").format(new Date()));
		if (this.siteIds != null && this.siteIds.size() > 0) {
			for (String item : this.siteIds) {
				System.out.println(item + "<" + item + ">");
				try {
					// 暂停秒数
					Thread.sleep(this.threadNo * 1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		System.out.println("结束线程号：" + this.threadNo + "(" + this.siteIds.size() + ")\t" + new SimpleDateFormat("HH:mm:ss.S").format(new Date()));
	}

}
